package com.xuecheng.content.convert;

import com.xuecheng.api.content.model.dto.TeachplanDTO;
import com.xuecheng.api.content.model.vo.TeachplanVO;
import com.xuecheng.content.entity.Teachplan;
import com.xuecheng.content.entity.ext.TeachlpanNode;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * <p></p>
 *
 * @Description:
 */
@Mapper
public interface TeachplanConvert {

    TeachplanConvert INSTANCE = Mappers.getMapper(TeachplanConvert.class);

    //将dto数据转为po并保存到数据中
    @Mapping(source = "teachPlanId", target = "id")
    Teachplan dto2entity(TeachplanDTO dto);

    //将po转为dto
    @Mapping(source = "id", target = "teachPlanId")
    TeachplanDTO entity2dto(Teachplan teachplan);

    //将vo转为dto
    TeachplanDTO vo2dto(TeachplanVO teachplan);


    @Mappings({
            @Mapping(source = "id", target = "teachPlanId"),
            @Mapping(source = "childrenNodes", target = "teachPlanTreeNodes")
    })
    TeachplanDTO node2dto(TeachlpanNode teachplanNode);
}
